﻿using System;
using System.Linq;
using System.Windows;
using System.Windows.Controls;

namespace DotNetUI.Controls
{
    /// <summary>
    /// GIF预览播放器
    /// </summary>
    public class DotNetGifViewer : MediaElement
    {
        public DotNetGifViewer()
        {
            Loaded += DotNetGifViewer_Loaded;
            MediaEnded += DotNetGifViewer_MediaEnded;
        }

        private void DotNetGifViewer_MediaEnded(object sender, RoutedEventArgs e)
        {
            Position = TimeSpan.FromMilliseconds(1);
            Play();
        }

        private void DotNetGifViewer_Loaded(object sender, RoutedEventArgs e)
        {
            LoadedBehavior = MediaState.Manual;
            Play();
        }
    }
}
